package com.wmlt.api;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.response.AlipayTradePagePayResponse;
import com.wmlt.aliPay.config.AlipayConfig;
import com.wmlt.entity.Order;
import com.wmlt.service.OrderService;
import com.wmlt.service.impl.OrderServiceImpl;
import com.wmlt.util.GetRequestJsonUtils;
import com.wmlt.util.QRCodeUtil;

public class OrderApi extends HttpServlet{

    @Override
    public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String path = req.getServletPath();
        resp.setContentType("text/json;charset=utf-8");
        switch (path) {
            case "/orderApi/queryOrderStatus":
                queryOrderStatus(req, resp);
                break;
            default:
                resp.setStatus(404);
                break;
        }
    }
    private void queryOrderStatus(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/text;charset=utf-8");
        String orderId=request.getParameter("orderId");
        System.out.println("获取到的订单id"+orderId);
        OrderService orderService=new OrderServiceImpl();
        int result = orderService.queryOrderStatus(orderId);
        response.getWriter().println(result);
    }

}